<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md4 layui-col-md-offset4">
            <form action="" class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        输入密码
                    </label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" id="password" lay-verify="required" name="password" placeholder="请输入密码" required="" type="password">
                        </input>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        确认密码
                    </label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" id="confirm_password" lay-verify="required|confirmPass" placeholder="请确认密码" required="" type="password">
                        </input>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        
                        <button class="layui-btn" lay-filter="formDemo" lay-submit="">
                            立即提交
                        </button>
                        <button class="layui-btn layui-btn-primary" type="reset">
                            重置
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
layui.use(['index','form','jquery'], function(){
  var form = layui.form;  
 　var $ = layui.jquery;
 form.verify({
    confirmPass:function(value){
        if($('input[name=password]').val() !== value)
            return '两次密码输入不一致！';
    }
});
 
    
  //监听提交
  form.on('submit(formDemo)', function(post_data){ 
    $.post(layui.setter.app_url+'User/saveChangePass', post_data.field, function(data) {        
         layer.msg(data.msg);
         setTimeout(function(){
            location.reload();
         },1000);
        
    }); 
    
    return false;
  });
 
 })
</script>
